//
//  ViewController.m
//  ColumnWidget
//
//  Created by -_Asuna on 16/8/7.
//  Copyright © 2016年 David. All rights reserved.
//

#import "ViewController.h"


@interface ViewController ()
@end

@implementation ViewController

- (void)viewDidLoad {
    [[UIApplication sharedApplication] setStatusBarHidden:YES];
    [self setWidget];
    [self.columnBackground insertSubview:self.column.view atIndex:0];
    [self setLandscapeTableView];
}

#pragma mark- Column sets
//
-(void)setWidget{
    self.column=[[ColumnWidget alloc] init];
    NSArray *array=[NSArray arrayWithObjects:@"头条",@"精选",@"娱乐", @"体育", @"网易号", @"本地", @"视频", @"财经", nil];
    [self.column setTitleArray:array];
    self.column.delegate=self;
}
#pragma mark- LandscapeTableView sets
//
-(void)setLandscapeTableView{
    [_tableView setDelegate:self];
    [_tableView setDateSource:self];
}
#pragma mark- LandscaoeTableView Delegate and DataSource
//
-(NSUInteger)numberOfCells{
    return 8;
}
-(UIView *)cellAtIndex:(NSUInteger)index{
    UIView *cell=[_tableView dequeueReusableCell];
    if(!cell){
        cell=[self getNewsViewAtIndex:index];
    }
    cell.frame=CGRectMake(index*CGRectGetWidth(_tableView.bounds), 0, CGRectGetWidth(_tableView.bounds), CGRectGetHeight(_tableView.bounds));
    cell.tag=index+100;
    return cell;
}
-(UIView *)getNewsViewAtIndex:(NSUInteger) index{
    UIImageView *imageView=[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"default"]];
    imageView.contentMode=UIViewContentModeScaleAspectFit;
    return imageView;
}

-(void)tableViewDidChangePageWithIndex:(NSUInteger)index{
    [_column setLocationWithIndex:index];
}
-(void)tableViewDidBeginScrollingFromIndex:(NSInteger)sourceIndex ToIndex:(NSInteger)destIndex offset:(CGFloat)offset{
  [_column fontAnimateFromIndex:sourceIndex toIndex:destIndex scale:offset/CGRectGetWidth(_tableView.bounds)];
}

#pragma mark- Column Delegate
-(void)isShowingIndex:(NSUInteger)index{
    [_tableView setLocationWithIndex:index];
}


//
//-(void)setScrollPage{
//    _newsView=[[EmbenddedScrollPage alloc] init];
//    _newsView.delegate=self;
//    UIEdgeInsets insets=UIEdgeInsetsMake(40, 0, 0, 0);
//    [self.newsView setScrollInset:insets];
//    NSMutableArray *embenddedArray=[[NSMutableArray alloc] init];
//    
//    for(int i=0;i<10;i++){
//       UIImageView *imageView=[[UIImageView alloc]initWithImage:[UIImage imageNamed:@"background"]];
//        [embenddedArray addObject:imageView];
//    }
//    [self.newsView setEmbenddedViews:embenddedArray];
//}
//
//-(id)askNewViewForIndex:(NSUInteger)index{
//    UIImageView *imageView=[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"background"]];
//    return imageView;
//}

@end





















